<!--{json width:"940",title:"回复帖子"}-->
<style type="text/css">
.post_form dt {width: 5%;}
.post_form dd {width: 93%;}
</style>
<form action="?post-post-fid-$fid-tid-$tid-pid-$pid-ajax-1.htm" method="post" id="post_form_$pid" class="post_form" target="_blank">
	<input type="hidden" name="FORM_HASH" value="{FORM_HASH}" />
	<!--{hook common_form_hash_after.htm}-->
	<dl>
		<!--{hook post_post_subject_before.htm}-->
		<dt>回复：</dt>
		<dd>$thread[subject]</dd>
		
		<!--{hook post_post_subject_after.htm}-->
		
		<dt><label for="message">内容：</label></dt>
		<dd style="position: relative;"><textarea name="message" id="post_message_$pid" style="width: 855px; height: 400px;">$message</textarea></dd>
		
		<!--{hook post_post_message_after.htm}-->
		
		<dt></dt>
		<dd>
			<input type="submit" class="button bigblue" id="post_submit_$pid" value="回复" />
			<input type="button" class="button biggrey" value="取消" id="post_cancel_$pid" />
			<!--{hook post_post_button_end.htm}-->
		</dd>
	</dl>
</form>

<!--{hook post_post_ajax_js_before.htm}-->

<script type="text/javascript">

function delay_execute(dialog, recall) {
	
	// hook post_post_delay_execute_start.htm

	$('#post_message_$pid')[0].focus();
	
	// 自动伸缩，自动提交
	$('#post_message_$pid').keyup(function(e) {
		if((e.ctrlKey && (e.which == 13 || e.which == 10)) || (e.altKey && e.which == 83)) {
			$('#post_submit_$pid').trigger('click');
			return false;
		}
	});
	
	$('#post_submit_$pid').click(function() {
		$('div.alert').remove();
		$('#post_submit_$pid').disable();
		var postdata = $("#post_form_$pid").serialize();
		$.post($('#post_form_$pid').attr('action'), postdata,  function(s){
			$('#post_submit_$pid').enable();
			
			var json = json_decode(s);
			if(error = json_error(json)) {alert(error); return false;}
			if(json.status <=0) {
				alert(json.message);
				return false;
			}
			json = json.message;
			if(json.message) {
				$('#post_message_$pid').parent().alert(json.message, {width: 250, delay: 3000});
				$('#post_message_$pid')[0].focus();
				return false;
			}
			
			var page = json.post.page;
			
			// hook post_post_submit_after_js.htm
			
			dialog.set_body('<div class="ok">回复成功！</div>');
			
			setTimeout(function(){
	 			dialog.close(1);
	 			window.location= '?thread-index-fid-$fid-tid-$tid-page-'+page+'-scrollbottom-1.htm';
	 		}, 500);
		});
		
		// hook post_post_ajax_post_after.htm
		 
		return false;
	});
	
	
	$('#post_cancel_$pid').click(function() {
		dialog.close(1);
	});
	
	// hook post_post_delay_execute_end.htm
	
	// hook common_form_hash_after_js.htm
}

</script>